package com.yssoft.service.inventory;


import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartRequest;

import com.yssoft.entity.production.TNonConformity;
import com.yssoft.entity.production.TNonConformityImg;
import com.yssoft.mapper.production.TNonConformityImgMapper;
import com.yssoft.mapper.production.TNonConformityMapper;
import com.yssoft.utils.AppUserHelper;
import com.yssoft.utils.AppUtil;
import com.yssoft.utils.UploadFile;

/**
 * @类名称: NonConformityStockService
 * @类描述: 不合格品库存Service
 * @作者: 于兴达
 * @创建时间:2018年9月12日09:19:33
 */
@Service
public class NonConformityStockService {
	
	@Resource
	private TNonConformityMapper nonConformityMapper;

    /**
     * @方法名称: getNonConformityList
     * @功能描述: 获取不合格品商品库存列表
     * @作者: 于兴达
     * @创建时间:2018年9月12日09:14:06
     * @param page
     * @param limit
     * @param companyId
     * @param type 
     * @return List<Map<String,Object>>
     */
	public List<Map<String, Object>> getNonConformityStockList(int page, int limit,
			Integer companyId,Integer tMid, String type) {
		HashMap<String,Object> param = new HashMap<>();
        param.put("companyId",companyId);
        param.put("tMid",tMid);
        param.put("type",type);
        int start = ((page - 1) * limit);
		int end = limit;
		param.put("start", start);
		param.put("end", end);
		List<Map<String, Object>>  nonConformityStockList = nonConformityMapper.getNonConformityStockList(param);
        return nonConformityStockList;
    }
	  /**
     * @方法名称: getNonConformityStockListyBatch
     * @功能描述: 获取不合格品各个批次的库存列表
     * @作者: 于兴达
     * @创建时间:2018年9月12日09:29:06
     * @param page
     * @param limit
	 * @param tnonId 
     * @return List<Map<String,Object>>
     */
	public List<Map<String, Object>> getNonConformityStockListyBatch(int page, int limit, Integer tnonId) {
		HashMap<String,Object> param = new HashMap<>();
        param.put("tnonId",tnonId);
        int start = ((page - 1) * limit);
		int end = limit;
		param.put("start", start);
		param.put("end", end);
		List<Map<String, Object>>  nonConformityStockList = nonConformityMapper.getNonConformityStockListyBatch(param);
        return nonConformityStockList;
	}
	/**
     * @方法名称: getGoodsList
     * @功能描述: 获取本企业成品和半成品
     * @作者: 于兴达
     * @创建时间:2018年9月14日09:29:06
     * @param page
     * @param limit
	 * @param companyId 
	 * @param type 
     * @return List<Map<String,Object>>
     */
	public List<Map<String, Object>> getGoodsList(int page, int limit,Integer companyId, String type,String name) {
		HashMap<String,Object> param = new HashMap<>();
        param.put("companyId",companyId);
        param.put("name",name);
        int start = ((page - 1) * limit);
		int end = limit;
		param.put("start", start);
		param.put("end", end);
		List<Map<String, Object>>  goodList = null;
		if("1".equals(type)){
			  goodList = nonConformityMapper.getGoodsListP(param);
		}
		if("2".equals(type)){
			 goodList = nonConformityMapper.getGoodsListS(param);
		}
        return goodList;
	}
}
